/*
 * @lc app=leetcode.cn id=1385 lang=typescript
 *
 * [1385] 两个数组间的距离值
 */

// @lc code=start
function findTheDistanceValue(
    arr1: number[],
    arr2: number[],
    d: number
): number {
    let count = 0;
    for (let i = 0; i < arr1.length; i++) {
        const element = arr1[i];
        const max = element + d;
        const min = element - d;
        if (
            arr2.every((i) => {
                return !(i >= min && i <= max);
            })
        )
            count++;
    }
    return count;
}
// @lc code=end
